package whu.o2o.adapter;

import java.util.ArrayList;

import whu.o2o.BaseActivity;
import whu.o2o.adapter.StudioAdapter.ViewHolder;
import whu.o2o.util.ConstantData;
import whu.o2o.vo.StudioVO;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import whu.o2o.R;

public class StudiosubmitAdapter extends BaseActivity{
	private Activity mContext;
	private LayoutInflater mLayoutInflater;
	private ArrayList<StudioVO> mList;
	private Drawable mValidatedDrawable;

	public StudiosubmitAdapter(Activity context, ArrayList<StudioVO> list) {
		mContext = context;
		mList = list;
		mLayoutInflater = LayoutInflater.from(mContext);
		mValidatedDrawable = mContext.getResources().getDrawable(R.drawable.ic_route_selected);
		mValidatedDrawable.setBounds(0, 0, mValidatedDrawable.getMinimumWidth(), mValidatedDrawable.getMinimumHeight());
	}


	public int getCount() {
		return mList.size();
	}

	
	public Object getItem(int position) {
		return mList.get(position);
	}


	public long getItemId(int position) {
		return position;
	}

	
	public View getView(int position, View convertView, ViewGroup parent) {
		StudioVO studiovo = mList.get(position);

		ViewHolder holder;
		if (convertView == null) {
			convertView = mLayoutInflater.inflate(R.layout.studiosubmit_listview_item, null);

			holder = new ViewHolder();
			holder.userHead = (ImageView) convertView.findViewById(R.id.ico);
			holder.userName = (TextView) convertView.findViewById(R.id.tv_studiosubmit_name);
			holder.cys = (TextView) convertView.findViewById(R.id.tv_studiosubmit_number);
			holder.mark = (TextView) convertView.findViewById(R.id.tv_studiosubmit_mark);
			holder.studioname = (TextView) convertView.findViewById(R.id.tv_studiosubmit_studioname);
			holder.age = (TextView) convertView.findViewById(R.id.tv_studiosubmit_age);
			holder.studioico = (ImageView) convertView.findViewById(R.id.iv_studiosubmit_studioico);
			holder.nameremind = (TextView) convertView.findViewById(R.id.tv_studiosubmit_nameremind);
	

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		
		
		holder.userName.setText(studiovo.getGuidevo().getName());
		holder.cys.setText(studiovo.getPeople());
		holder.gzrs.setText(studiovo.getFocus());
		holder.mark.setText(studiovo.getLabel());
		holder.studioname.setText(studiovo.getName());
		holder.age.setText(studiovo.getGuidevo().getAge());
		
		if (ConstantData.Data.VALIDATED == studiovo.getValidated()) {
			holder.userName.setCompoundDrawables(null, null, mValidatedDrawable, null);
		} else {
			holder.userName.setCompoundDrawables(null, null, null, null);
		}

		return convertView;
	}

	static class ViewHolder {
		ImageView userHead;
		ImageView studioico;
		TextView userName;
		TextView cys;//成员数
		TextView gzrs;//关注人数
		TextView mark;//标签
		TextView studioname;//工作室名称
		TextView age;//成员数
		TextView nameremind;//名字提醒
		TextView grade;//关注人数
	}
}
